<template>
  <div class="flex flex-column justify-center pt-30px">
    <input id="menu" type="checkbox" />
    <label @click="collapseMenu()" for="menu"></label>
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo mt-20px"
      @open="handleOpen"
      :collapse="collapse"
      @close="handleClose"
    >
      <el-sub-menu index="1">
        <template #title>
          <el-icon><location /></el-icon>
          <span>组件</span>
        </template>
        <el-menu-item-group title="基本控件">
          <el-menu-item
            v-for="(item, index) in menuList"
            @click="jumpLink(item.path)"
            :key="index"
            >{{ item.path }}</el-menu-item
          >
        </el-menu-item-group>
      </el-sub-menu>
      <el-menu-item index="2">
        <el-icon><Promotion /></el-icon>
        <span>示例</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>
<script setup>
const router = useRouter()
const collapse = ref(true)
const collapseMenu = () => {
  collapse.value = !collapse.value
}
const menuList = ref()
const jumpLink = path => {
  router.push(path)
}
onMounted(() => {
  menuList.value = router.options.routes
  console.log(router.options.routes)
})
</script>
<style lang="scss" scoped>
#menu {
  visibility: hidden;
}
label {
  position: absolute;
  box-shadow:
    0 0 1px 0 rgba(#0b0b0b, 0.15),
    0 6px 12px 0 rgba(#060606, 0.15);
  display: block;
  width: 20px;
  height: 5px;
  margin-left: 10px;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  -webkit-transition: 0.6s;
  transition: 0.6s;
}
label:before {
  content: '';
  width: 20px;
  height: 5px;
  background: #fff;
  position: absolute;
  transform: translateY(-30px);
  -webkit-transform: translateY(-8px);
  border-radius: 5px;
  -webkit-transition: 0.6s;
  transition: 0.6s;
}
label:after {
  content: '';
  width: 20px;
  height: 5px;
  background: #fff;
  position: absolute;
  transform: translateY(30px);
  -webkit-transform: translateY(8px);
  border-radius: 5px;
  transition: 0.6s;
  -webkit-transition: 0.6s;
}

/* animation when checked */
#menu:checked + label {
  width: 120px;
  height: 3px;
  border-radius: 0px;
  cursor: pointer;
  -webkit-transition: 0.6s;
  transition: 0.6s;
  box-shadow: 0;
}
#menu:checked + label:before {
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg) translateY(15px) translateX(-15px);
  box-shadow:
    0 0 1px 0 rgba(#0b0b0b, 0.15),
    0 6px 12px 0 rgba(#060606, 0.15);
}
#menu:checked + label:after {
  transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg) translateY(-15px) translateX(-15px);
  box-shadow:
    0 0 1px 0 rgba(#0b0b0b, 0.15),
    0 6px 12px 0 rgba(#060606, 0.15);
}
</style>
